package com.quan.xczs.rpc.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import tk.mybatis.mapper.entity.Condition;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.quan.base.common.base.service.support.BaseService;
import com.quan.base.common.utils.Paginator;
import com.quan.xczs.rpc.api.XczsUserInvitedService;
import com.quan.xczs.rpc.dao.mapper.XczsUserInvitedMapper;
import com.quan.xczs.rpc.model.XczsUser;
import com.quan.xczs.rpc.model.XczsUserInvited;

@Service
public class XczsUserInvitedServiceImpl extends BaseService<XczsUserInvited, Integer> implements XczsUserInvitedService {
	
	@Autowired
	private XczsUserInvitedMapper mapper ;
	
	@Override
	public PageInfo<XczsUser> selectInvitedDetailByRefereeOpenid(Paginator paginator, XczsUser entity, String refereeOpenid) {
		Page<XczsUser> page = PageHelper.startPage(paginator.getPage(), paginator.getRows()) ;
		this.mapper.selectInvitedDetailByRefereeOpenid(paginator, entity, refereeOpenid) ;
		return new PageInfo<XczsUser>(page) ;
	}

	@Override
	public PageInfo<XczsUser> selectMyInvitedByRefereeOpenid(Paginator paginator, String refereeOpenid) {
		Page<XczsUser> page = PageHelper.startPage(paginator.getPage(), paginator.getRows()) ;
		this.mapper.selectMyInvitedByRefereeOpenid(paginator, refereeOpenid) ;
		return new PageInfo<XczsUser>(page) ;
	}

	@Override
	public int countInvitedByRefereeOpenid(String refereeOpenid) {
		Condition condition = new Condition(XczsUserInvited.class) ;
		condition.createCriteria().andEqualTo("refereeOpenid", refereeOpenid);
		return this.mapper.selectCountByCondition(condition);
	}

	@Override
	public int deleteByRefereeOpenid(String refereeOpenid) {
		Condition condition = new Condition(XczsUserInvited.class) ;
		condition.createCriteria().andEqualTo("refereeOpenid", refereeOpenid);
		return this.mapper.deleteByCondition(condition) ;
	}

}
